package com.itlong.cloud.resource;

import com.itlong.cloud.POJO.DTO.operate.DeadQueueGetPageDTO;
import com.itlong.cloud.POJO.PO.TimeTaskDeadMessageQueuePO;
import com.itlong.cloud.project.operate.ITimeTaskDeadMessageQueueServiceClient;
import com.itlong.cloud.service.ITimeTaskDeadMessageQueueService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      死信消息管理暴露接口实现类
 * </desc>
 *
 * @createDate 2017/11/29
 */
@RestController
public class TimeTaskDeadMessageQueueServiceResource implements ITimeTaskDeadMessageQueueServiceClient {

    @Autowired
    ITimeTaskDeadMessageQueueService iTimeTaskDeadMessageQueueService;

    /**
     * <desc>
     *      获取分页数据
     * </desc>
     *
     * @param pageDTO 查询参数DTO
     * @return page模型
     * @author Jiaqi.X
     * @createDate 2017/09/25
     */
    @RequestMapping(path = "/operate/system/deadQueue/getPage")
    @Override
    public Page<TimeTaskDeadMessageQueuePO> getPage(@RequestBody DeadQueueGetPageDTO pageDTO) throws Exception {
        return iTimeTaskDeadMessageQueueService.getPage(pageDTO);
    }

    /**
     * <desc>
     *      发送死信
     * </desc>
     *
     * @param po
     * @author Jiaqi.X
     * @createDate 2017/11/29
     */
    @RequestMapping(path = "/operate/system/deadQueue/sendMessage")
    @Override
    public void sendMessage(@RequestBody TimeTaskDeadMessageQueuePO po) throws Exception{
        iTimeTaskDeadMessageQueueService.sendMessage(po,true);
    }

    /**
     * <desc>
     *     定时任务检测错误的死信消息进行重发
     * </desc>
     *
     * @author Jiaqi.X
     * @createDate 2018/01/27
     */
    @RequestMapping(path = "/operate/system/deadQueue/autoRedirectSendDeadMessage")
    @Override
    public void autoRedirectSendDeadMessage() throws Exception {
        iTimeTaskDeadMessageQueueService.autoRedirectSendDeadMessage();
    }
}
